package org.i1510.base.utils;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

public class IDGenerator {
	/**
	*@author Kenshinbo@163.com
	*@描述：获取ID生成器
	*@return 
	*@version  IDGenerator.java,v 1.1 Dec 7, 2010 10:43:48 AM KB
	*/
	public static String getGenerateID() {
		String now = Long.toHexString(System.currentTimeMillis());
		String rtnVal = now+UUID.randomUUID();
		rtnVal = rtnVal.replaceAll("-", "");
		return rtnVal.substring(0, 32);
	}
	
	/**
	*@author Kenshinbo@163.com
	*@描述：获取ID生成器产生时间
	*@param id
	*@return 
	*@version  IDGenerator.java,v 1.1 Dec 7, 2010 10:43:59 AM KB
	*/
	private static Date getIDTime(String id) {
		String time = id.substring(0, 11);
	
		return new Date(Long.parseLong(time, 16));
	}

	/**
	*@author Kenshinbo@163.com
	*@描述：测试方法
	*@param args 
	*@version  IDGenerator.java,v 1.1 Dec 7, 2010 10:44:11 AM KB
	*/
	public static void main(String[] args) {
		System.out.println(getGenerateID());
		System.out.println("************************************************");
		List list = new ArrayList();
		Map map1 = new HashMap();
		Map map2 = new HashMap();
		map1.put("atrr1", "1");
		map1.put("atrr2", "2");
		map2.put("atrr1", "1");
		map2.put("atrr2", "2");
		System.out.println(map1.equals(map2));
		list.add(map2);
		System.out.println(list.contains(map1));
		System.out.println("sss".split(",")[0]);
		System.out.println(getIDTime("12cc0171f5e3da0211b9ee94434804a4"));
	
	}
}
